package main

func main() {

	var temp []int = []int{8, 2, 188,88,44,174, 145, 14, 58}
	BubbleSort(temp)

}

//冒泡排序
func BubbleSort(values []int) []int{

	length := len(values)
	flag := true
	for i, _ := range values {
		flag = false
		for j := 0; j < length-i-1; j++ {
			if values[j] > values[j+1] {
				values[j],values[j+1] = values[j+1],values[j]
				flag = true
				continue
			}
		}
		if flag == false {
			break
		}
	}

	return values
}
